﻿USE CodeCamp;
GO

--********************************************************
-- Drop Tables - start with 
--********************************************************
DECLARE @DropTables bit SET @DropTables = 0;
--DECLARE @DropTables bit SET @DropTables = 1;
IF @DropTables = 1 BEGIN

	DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)

	SET @TableName = N'cc_Sponsors'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_SessionPresenters'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_ScheduledSessions'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_TimeSlots'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Rooms'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Tasks_TimeSlots'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_TaskTimeSlots'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Tasks'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_SessionTags'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Tags'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_SpeakerRateEvent'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Sessions'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_SpeakerRateSpeakers'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_PresenterBiographies'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Presenters'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_ShirtSizes'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_IndividualContributors'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_CommunitySponsors'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Buildings'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_BannedTags'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Events'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END


	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'__MigrationHistory'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END

END;
GO

--********************************************************
--********************************************************
--********** CREATE SCHEMA
CREATE TABLE [cc_BannedTags] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [Name] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_cc_BannedTags] PRIMARY KEY ([Id])
)
CREATE TABLE [cc_Buildings] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [Name] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_cc_Buildings] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_Buildings]([EventId])
CREATE TABLE [cc_Events] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [DisplayName] [nvarchar](128) NOT NULL,
    [ShortName] [nvarchar](32) NOT NULL,
    CONSTRAINT [PK_cc_Events] PRIMARY KEY ([Id])
)
CREATE TABLE [cc_CommunitySponsors] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [Name] [nvarchar](128) NOT NULL,
    [Url] [nvarchar](1024) NOT NULL,
    CONSTRAINT [PK_cc_CommunitySponsors] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_CommunitySponsors]([EventId])
CREATE TABLE [cc_IndividualContributors] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [FirstName] [nvarchar](128) NOT NULL,
    [LastName] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_cc_IndividualContributors] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_IndividualContributors]([EventId])
CREATE TABLE [cc_Presenters] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [FirstName] [nvarchar](128) NOT NULL,
    [LastName] [nvarchar](128) NOT NULL,
    [TwitterName] [nvarchar](128),
    [EmailAddress] [nvarchar](128) NOT NULL,
    [UserIdentityIssuer] [nvarchar](256) NOT NULL,
    [UserIdentityProvider] [nvarchar](256) NOT NULL,
    [UserIdentityClaimType] [nvarchar](256) NOT NULL,
    [UserIdentityClaim] [nvarchar](512) NOT NULL,
    [UniqueUserIdentifier] [nvarchar](1050) NOT NULL,
    [UserClaimEmailAddress] [nvarchar](128),
    [WebsiteUrl] [nvarchar](1024),
    [BlogUrl] [nvarchar](1024),
    [MobilePhone] [nvarchar](20),
    [ShirtSize] [nvarchar](10),
    [CreatedUTC] [datetime] NOT NULL,
    CONSTRAINT [PK_cc_Presenters] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_Presenters]([EventId])
CREATE TABLE [cc_SessionPresenters] (
    [PresenterId] [int] NOT NULL,
    [SessionId] [int] NOT NULL,
    [Event_Id] [int],
    CONSTRAINT [PK_cc_SessionPresenters] PRIMARY KEY ([PresenterId], [SessionId])
)
CREATE INDEX [IX_PresenterId] ON [cc_SessionPresenters]([PresenterId])
CREATE INDEX [IX_SessionId] ON [cc_SessionPresenters]([SessionId])
CREATE INDEX [IX_Event_Id] ON [cc_SessionPresenters]([Event_Id])
CREATE TABLE [cc_Sessions] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [Title] [nvarchar](128) NOT NULL,
    [Description] [nvarchar](4000) NOT NULL,
    [SessionMaterialsUrl] [nvarchar](128),
    [CreatedUTC] [datetime] NOT NULL,
    CONSTRAINT [PK_cc_Sessions] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_Sessions]([EventId])
CREATE TABLE [cc_ScheduledSessions] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [RoomId] [int] NOT NULL,
    [SessionId] [int] NOT NULL,
    [TimeslotId] [int] NOT NULL,
    CONSTRAINT [PK_cc_ScheduledSessions] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_RoomId] ON [cc_ScheduledSessions]([RoomId])
CREATE INDEX [IX_SessionId] ON [cc_ScheduledSessions]([SessionId])
CREATE INDEX [IX_TimeslotId] ON [cc_ScheduledSessions]([TimeslotId])
CREATE TABLE [cc_Rooms] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [BuildingId] [int] NOT NULL,
    [Name] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_cc_Rooms] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_BuildingId] ON [cc_Rooms]([BuildingId])
CREATE TABLE [cc_TimeSlots] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [Name] [nvarchar](128) NOT NULL,
    [Date] [datetime] NOT NULL,
    [StartTime] [time](7) NOT NULL,
    [EndTime] [time](7) NOT NULL,
    CONSTRAINT [PK_cc_TimeSlots] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_TimeSlots]([EventId])
CREATE TABLE [cc_SessionTags] (
    [SessionId] [int] NOT NULL,
    [TagId] [int] NOT NULL,
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    CONSTRAINT [PK_cc_SessionTags] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_SessionId] ON [cc_SessionTags]([SessionId])
CREATE INDEX [IX_TagId] ON [cc_SessionTags]([TagId])
CREATE TABLE [cc_Tags] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [Name] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_cc_Tags] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_Tags]([EventId])
CREATE TABLE [cc_SpeakerRateSpeakers] (
    [PresenterId] [int] NOT NULL,
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [SpeakerUrl] [nvarchar](256),
    CONSTRAINT [PK_cc_SpeakerRateSpeakers] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_PresenterId] ON [cc_SpeakerRateSpeakers]([PresenterId])
CREATE TABLE [cc_PresenterBiographies] (
    [Id] [int] NOT NULL IDENTITY,
    [PresenterId] [int] NOT NULL,
    [Content] [nvarchar](4000) NOT NULL,
    CONSTRAINT [PK_cc_PresenterBiographies] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_PresenterId] ON [cc_PresenterBiographies]([PresenterId])
CREATE TABLE [cc_SpeakerRateEvent] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [EventUrl] [nvarchar](256),
    CONSTRAINT [PK_cc_SpeakerRateEvent] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_SpeakerRateEvent]([EventId])
CREATE TABLE [cc_Sponsors] (
    [Id] [int] NOT NULL IDENTITY,
    [ImageUrl] [nvarchar](1024) NOT NULL,
    [ImageHeight] [int] NOT NULL,
    [ImageWidth] [int] NOT NULL,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [Name] [nvarchar](128) NOT NULL,
    [Url] [nvarchar](1024) NOT NULL,
    CONSTRAINT [PK_cc_Sponsors] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_Sponsors]([EventId])
CREATE TABLE [cc_Tasks] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [EventId] [int] NOT NULL,
    [Name] [nvarchar](128) NOT NULL,
    [Notes] [nvarchar](1024),
    CONSTRAINT [PK_cc_Tasks] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_EventId] ON [cc_Tasks]([EventId])
CREATE TABLE [cc_Tasks_TimeSlots] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [TaskId] [int] NOT NULL,
    [TaskTimeslotId] [int] NOT NULL,
    CONSTRAINT [PK_cc_Tasks_TimeSlots] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_TaskId] ON [cc_Tasks_TimeSlots]([TaskId])
CREATE INDEX [IX_TaskTimeslotId] ON [cc_Tasks_TimeSlots]([TaskTimeslotId])
CREATE TABLE [cc_TaskTimeSlots] (
    [Id] [int] NOT NULL IDENTITY,
    [IdOld] [int],
    [Date] [datetime] NOT NULL,
    [StartTime] [time](7) NOT NULL,
    [EndTime] [time](7) NOT NULL,
    [VolunteersNeeded] [int] NOT NULL,
    CONSTRAINT [PK_cc_TaskTimeSlots] PRIMARY KEY ([Id])
)
ALTER TABLE [cc_Buildings] ADD CONSTRAINT [FK_cc_Buildings_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_CommunitySponsors] ADD CONSTRAINT [FK_cc_CommunitySponsors_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_IndividualContributors] ADD CONSTRAINT [FK_cc_IndividualContributors_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_Presenters] ADD CONSTRAINT [FK_cc_Presenters_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_SessionPresenters] ADD CONSTRAINT [FK_cc_SessionPresenters_cc_Presenters_PresenterId] FOREIGN KEY ([PresenterId]) REFERENCES [cc_Presenters] ([Id])
ALTER TABLE [cc_SessionPresenters] ADD CONSTRAINT [FK_cc_SessionPresenters_cc_Sessions_SessionId] FOREIGN KEY ([SessionId]) REFERENCES [cc_Sessions] ([Id])
ALTER TABLE [cc_SessionPresenters] ADD CONSTRAINT [FK_cc_SessionPresenters_cc_Events_Event_Id] FOREIGN KEY ([Event_Id]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_Sessions] ADD CONSTRAINT [FK_cc_Sessions_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_ScheduledSessions] ADD CONSTRAINT [FK_cc_ScheduledSessions_cc_Rooms_RoomId] FOREIGN KEY ([RoomId]) REFERENCES [cc_Rooms] ([Id])
ALTER TABLE [cc_ScheduledSessions] ADD CONSTRAINT [FK_cc_ScheduledSessions_cc_Sessions_SessionId] FOREIGN KEY ([SessionId]) REFERENCES [cc_Sessions] ([Id])
ALTER TABLE [cc_ScheduledSessions] ADD CONSTRAINT [FK_cc_ScheduledSessions_cc_TimeSlots_TimeslotId] FOREIGN KEY ([TimeslotId]) REFERENCES [cc_TimeSlots] ([Id])
ALTER TABLE [cc_Rooms] ADD CONSTRAINT [FK_cc_Rooms_cc_Buildings_BuildingId] FOREIGN KEY ([BuildingId]) REFERENCES [cc_Buildings] ([Id])
ALTER TABLE [cc_TimeSlots] ADD CONSTRAINT [FK_cc_TimeSlots_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_SessionTags] ADD CONSTRAINT [FK_cc_SessionTags_cc_Sessions_SessionId] FOREIGN KEY ([SessionId]) REFERENCES [cc_Sessions] ([Id])
ALTER TABLE [cc_SessionTags] ADD CONSTRAINT [FK_cc_SessionTags_cc_Tags_TagId] FOREIGN KEY ([TagId]) REFERENCES [cc_Tags] ([Id])
ALTER TABLE [cc_Tags] ADD CONSTRAINT [FK_cc_Tags_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_SpeakerRateSpeakers] ADD CONSTRAINT [FK_cc_SpeakerRateSpeakers_cc_Presenters_PresenterId] FOREIGN KEY ([PresenterId]) REFERENCES [cc_Presenters] ([Id])
ALTER TABLE [cc_PresenterBiographies] ADD CONSTRAINT [FK_cc_PresenterBiographies_cc_Presenters_PresenterId] FOREIGN KEY ([PresenterId]) REFERENCES [cc_Presenters] ([Id])
ALTER TABLE [cc_SpeakerRateEvent] ADD CONSTRAINT [FK_cc_SpeakerRateEvent_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_Sponsors] ADD CONSTRAINT [FK_cc_Sponsors_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_Tasks] ADD CONSTRAINT [FK_cc_Tasks_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_Tasks_TimeSlots] ADD CONSTRAINT [FK_cc_Tasks_TimeSlots_cc_Tasks_TaskId] FOREIGN KEY ([TaskId]) REFERENCES [cc_Tasks] ([Id])
ALTER TABLE [cc_Tasks_TimeSlots] ADD CONSTRAINT [FK_cc_Tasks_TimeSlots_cc_TaskTimeSlots_TaskTimeslotId] FOREIGN KEY ([TaskTimeslotId]) REFERENCES [cc_TaskTimeSlots] ([Id])
CREATE TABLE [__MigrationHistory] (
    [MigrationId] [nvarchar](255) NOT NULL,
    [CreatedOn] [datetime] NOT NULL,
    [Model] [varbinary](max) NOT NULL,
    [ProductVersion] [nvarchar](32) NOT NULL,
    CONSTRAINT [PK___MigrationHistory] PRIMARY KEY ([MigrationId])
)
BEGIN TRY
    EXEC sp_MS_marksystemobject '__MigrationHistory'
END TRY
BEGIN CATCH
END CATCH
INSERT INTO [__MigrationHistory] ([MigrationId], [CreatedOn], [Model], [ProductVersion]) VALUES ('201205151741345_Schema1', '2012-05-15T17:41:47.808Z', 0x1F8B0800000000000400ECBD07601C499625262F6DCA7B7F4AF54AD7E074A10880601324D8904010ECC188CDE692EC1D69472329AB2A81CA6556655D661640CCED9DBCF7DE7BEFBDF7DE7BEFBDF7BA3B9D4E27F7DFFF3F5C6664016CF6CE4ADAC99E2180AAC81F3F7E7C1F3F22FEC7BFF71F7CFC7BBC5B94E9655E3745B5FCECA3DDF1CE4769BE9C56B36279F1D947EBF67CFBE0A3DFE3E8374E1E9FCE16EFD29F34EDF6D08EDE5C369F7D346FDBD5A3BB779BE93C5F64CD78514CEBAAA9CEDBF1B45ADCCD66D5DDBD9D9D83BBBB3B777302F111C14AD3C7AFD6CBB658E4FC07FD79522DA7F9AA5D67E517D52C2F1BFD9CBE79CD50D317D9226F56D934FFECA3136A71922D56E3D3674F8F9F7F941E97454658BCCECBF3F74469E72150FAC87646DD9D125AEDF59BEB55CE5D7EF6D1936CB9CC676FB20BBF1935FCBDF2EBE003FAE8655DADF2BABD7E959FEBCB67B38FD2BBE17B77BB2FDAD7BC77D03FFDB66CEFED7D94BE5897653629E983F3AC6CF28FD2D5A78F5EB7559D7F9E2FF33A6BF3D9CBAC6DF37A897773C65FE9F068F5E9ED48F1F0EECE1E487197065BB5594B53DC43BC87E697E530A66DBDCE6F82807F0D80D76D4DFCF651FAAC7897CF9EE7CB8B766E87FB45F6CE7CB2BB77F051FAD5B220F6B49DF4C8E3F7FAF8AE9BD0CDD3BC2E4AB0FC8F66F91B9EE5D34B42F6E6D1FEDCB30AF5FA22BB2C2E982EB1417C94BECA4BFEB699172B513863C337BFBF367956578B5715BA08BFF9FD5F57EB7A8A4154D1AFDF64F545DEDE1EA35755B568A218E19BDFDFB2B38750F085EDD0E0137E6BB0FD5AB224A4F891207DB382F4B468566576FD4312854EE7AFE755DD7E8DAE31CCF7EC7990E50D73C6D9FED682D865FC0139BD2D5627D562B15E1213BD5E113E551DC7AEDBAA8F65BC450FDB8166EF8BF5D972565C1633F2B7C8F3A2A99CACDB21D4A34DFBF86F68D61BC4A6B6EF3B929775DED07BF900F6F6EB3EC69DAF7A5876BF7F5FCC5EE70D7CE5385EFA651FABE08B1E4EE1B75F13A31B48A6B0FB6D1D92034D7A466EA8DDFB5ABBD7AB3C7B9BD7AF487B33C8019A765A45881B6DD1A772BCD97B937B93461854049BE5FFC3C49EC2983836F4451F13FB610F0BF7CDFB63D0BC1D42A1791BC3C17C1A41C27EF5DE5814144D96D5001F996F23D804DFF4310ABFFE2027AAABE87FE44F7DC3FE14CFD1CDA3FD7F4560D2E9F5ABBA7CDF4E77F6F6DFBBD7AF110E7D6D3FA76B396E7087BE964845DD8E1FC9D5FF1BE5EA5951375F27DEF80684EB79F643EBF96B08D837E08D7745ED369EFBD79237EBF0FD48C6FEDF29633F1F64ACEBF95D1598F06FBCF35B69C6455694C7B3198945F38D767EAB917FD5E4B561F2B3A6599358BE1F0E7BF73FFD2671A0AF48EBFC5C63715266C50208FCBF008DF744E1FEEEFB27D7BA282C8B5FB4CE1D22E7C57BCFC7EECEFD9D0F468310600AFCAC49C86DC4F3BBF9A429DAFC1B77AE6FD3F793B2BAF839E9F88B6A5294F9CB79B57C6F09D834EDB7E9FAF5BCA8DBD7C50FDEB7E3DD0FEDF8A4CE61FABF7A73627A7E4A7F2378BF9973BF86CBF61E29C8AE6B3694A2BC2D523725FC825CA4EBCC396EFDC464A4D5509632D6F47D33355E2A4E7FBD31F7A7BF0E8C6243BB4D79C07EE3F71D897DF349515DD4D96A5EE437A4AC4DC3EBF85036B51B4E66C71A7F50A2AA3BD95FC7D9B72FF7BDFE687BEDF3EBC40841571F12A27A38BC17989B1964D382C1D717D2AE6EB9853CDF167305753BBC6DE30D589B658E1B71360D3F284E35187D0DC6FD3A1C7833C7FC284A7540DE146DF9DE1EC287474B4FF3665A172B21D47B75BEBFB3F3C10EB172E41734F775412F7C0DD7F083DDE11FB29774CB05D1018DF075FD239299D9BACC679BD76A3BADA22A6CA04DDFA7186AF8BEFEC4D7F4EDDE47FDDEE8D77D20EE83CB91EEFB0DF87ADF0E61EA37F93027A7336B3FB215DFB0AD7855558B9B077B2BADF9A160CC2AEE7BC31964770CEE769A455A6E502B68D05782D156EFAD0C8DA4DD06D1F7518137A2DB95E2DB626C66EA7628BBD61B70B64BF837226D5B7E90EFC913FE73A54CFEFFAA4C9EAC8B72465ED27B4B70070EFEFD46FDAEF7D41B661C51FE6619772D1C4F075FF4F838FCF67D25EE6B3A4CB7536B37BA4A81F2FB5AE26675C08F44EE9B15B96F24D6FB21C95B37D423AABF7F88D3158C36AB5B7953207D2D28A7CBD9FBC3F81AC196B55DBD682BFCA6A73D3A5FFF90D4C7FB59EE1BD548CFC67F2D55E2428C1F29936F58997C538E7CF6FE1EC0D7F38E2D2BDC325C1DC862C422DADBE2073EBC01376E12C58B3B1EC649FEFF015EEE8F84E49B1792FF2F59DCAF63A288E7FAD6C97CD8374CF69BF7151CC7E737E6A2360BD0861C942F5F5F4B80FA2B913F92A76F589EBEB9854199A0F7CFD9EFDDFFF47D73F65F773151D9E98356CB7B06E3364BEB5F8BFBFB8BD73FE2FE9F1DDE3DA9080A74EE7B31EED75AF2FA9AACDBE78538EB6E6AD763DD8D8D3F88753DA1106BF623C6FD66D5F637E20631909F5B85BD6165B4C3429125D2688B4D0ADA6FF681FC4DB8563FF2463A682EB28BFCFDF96977676FFFBDF568ACEB6FE7C5C5DC6AF16199B811D0778B593BFF4038FFEF10F11F52A4D3E9F587C4035F4BABB0E0C69489F7454487F8DF7E90EA7893356F7FA4377E242BB6D7AACD9BF7ED76B3B47C532618AC1ACB46984F23E908FBD5FBE623F06A6373D4F19C44D8E6F76749EA20D6F9BA979D88B5F9A0144508F04782FD0D0B36C87BF3606F866126E8BD616D64D86F8A4B637234C4C9EF839F5B41BA1D9EB115A70DCD6E83776F7DEA6B4BD98F646C00CD0F95B1FFAFAF047760FC6455AE298391D7CD8B3C9FE537CEE2FB08D4D7B050EF2B53B7B0585F6B25F7B869AA69C108EB804EAAC562BDA4A6A1531C928366241544E2CD9D0E10070654E8B624DF655DB6C5AA2CA6F4E1671F7DAB47F41B7BB15471BDA8631282DEED81262590D790C6ACA4345FD3D659B16CFB1AA3584E8B5556DE0A8BCEDBB7D438981ADB4FF79BA7F92A5F4269DC8AD8B741C0BAC47D2C6C671D8D7813A91EDFF59868336F9D2D67C565315B3324726A27EBF64606DBF04E8CCBA2CDDF87D536F5F743E6B75BA0729B39FF40A6BBC504DC068B9F5BCE7319ECCDDCD66917E3302FC37E7BAEEAC2FD2173D240F7B799B70FE49E0182DEA6E79F5B8ED1156B87BF9BF7A1491E7E25C647DDD6EFC34E1B7A8A70D66017DF1077DD8CCD6DA6FB0319ED66E2DF068960F1F0E792EF6ED05341AB0DDCF53598EAE74643453BBFCD8C7D336CF3FB9F5EFE7F4A3BBDAAAAC5EFFF645D943364068766346815E31234781F1609014658C4A2F4B3C325D1FE6F335B1FC8255142DEA65FF3CECF19A3BCA6C4C26C5DE633C3E83CE5832A20D63AAA5E3A0DDF8789E29D449829C69DDF10236DC4E13613FB810CB591D0B7E91FEDFFDFC354860B6E3DE5F6E7CF326B999F11EE1A00FFB3C5601D4C6E33C7DF348F75887E1B14F4959F334EB349ADCDEE50D82CC6552EE1767B6EEA40FD217B44F1DE6F33691FC8377162DEA6E39F5B9FA8C7EF036B031BD4457F0DE367492FF513BB37B3EA37C45737E2729B99FE4016BB91F0B7C1C1BCF373C77082FC9BECE26603D86BBA2168A356EFC55C7DD83F7C733788C36D66F243B96990B8B7E9FCE7DCC411DA375837D3226AD8DE8F591CAC1FB639EB767C9BB9F940C6E811EE367DFE1C1B31C7CB98D95BC83CB3FDCF822E91FFF7AD531FE037C421F1BE6F33651FC8267162DEA6636AFE73CD295E9AF37636A8F7C2CF7A72FAE7DA2A0D62729B29FE66786B90E8B741E1E7DA42BD5EE5D9DBBC7E95B5B9FE7A9BC5900D2F4539AED7FEBD786E536F11BEFB595F12B9053EB799FA0FE5BE5B4CC26DD0F8B95F16B1183C29AA8B3A5BCDAF6FC1839B5EEAF060C815B6FDFBF0E0C6DE7E0E78F036F8DC66F23F90076F3309B741E3E79E07D595EC68F46690FD06DAC7382FEA79EF8CC77D56B819FCB099BDAD397F0F9A781A46F0B961DD32DAFC067B1025CE2DAD81DFCB0F39E2D98CC56D58FE03256F33B16F83C0CF712CB42200557D234B79ADE29CC40DDE8F817C983F74BE89747E9BD9FA60768910F236FDFEDC72C99BAC797B6302C5348967509AB71FA55FDC9A393C683F64CEE8F77C9BE9F940B6E813EF369DFEDCF344E327B66986374D67A7ED1097B866EFA34C621D441827C686DF20DF0C60709BB9FC06186880C0B7E91DEDFFDFC44837AE2A6D78E7679DB136AE2BF9C8FFD018EDE76075E91613701B2CFCF77ECE18F0C9BA2867C5F2A62582B0598CCD4C8BF761B00ED41FB2B58BF77E9B99FB40FE8913F3361DFF30ADDE29BDD35ED33B2DBD91D78AC14935CB4FB2C5EAE904DFE4EFFA2C83B75EE7ADE1AF6CB9CC6794C76E3E4AE53B9F67CC97111EE980519245A158CEBB0108532F0641B9EC86D74FAAC562BDC447E2C8C62075DBDC08F46C392B2E8BD99A67A7AD8BC9BA8D438E36BC11BC9745E883F4C2F51BC0F473127D68FD1CC0ED806E80753388CE3A7F1456A7CD8D405F55D52206089FDFF8B251E83100CE38DE8E320352E3AFBCDD844D1CC26D5EEDA776A3B844B2EAB7654993AF2BF28DCCE9E54A6F8FF2A0A8F7D33E37021D14F6DBCA38FB0BD16980477E9B973DF72D0AC56F700B781B9934F0E23AC03C5331AC17D59548BDC603DA31E67430CAC64188BF60DD0F3BB6A872EED9C81BE11A07C4836B18A94308DF6852BB5B5029AABF8749B5A9F9F0B836BC1523DA90F1D940B94D3DFC6C92CFA5F40749D66D323C884ECB18697C53B7811C5D483F9B24E82DF57AA6B64F8D0DAD878733FC528C4611AF6003A936C08E506D18E8D7A7DC30EB840D6E1CC330DB383FE4664AFC1058062ECBEFEFFCE3FEC0C306C32807ED620357A769C3A8431091517B3EFE070FBCEBF4FDFEE2BC45663EDA70C3DCC5DA4739A1EF9A6E628928D80891A274FE260864BDE35BD0C8B47D8FF1D89FDF38A5CCCF08B186007E0D7AD904CFA00EE9B4181E41D8304611CF3FDB40890E9C9F4D3DD223BAF3106FC12EF18CE6E659ED6534BF3986E9E5306F43F9AF4334E98F82AD8DC2D56F75A3E5F01A6F304212FCDD6C877C683FCB4294993C634C7EEC971B58DEB4894ACD4DE3756FFFACCA8AA32AC7D91BA71C2D6E35413C49DFC854CBFFFB9C1F01F1F547EFF98D37B27EBFED8DE3E8BDF2B3E09EFE7044A29F40B9C1ADDFD47EC3E836BC16A55D2CFBB3897A9BE0FF6CBBF7FD54D1661A6E6C3F3CC64DAF6D0C21A5BD26BA6E134CC63AF8D926A2AAD5BECCF4E937D4747864036FC4A816D7C3B782362CA9DF28A5BA29C40D6165BCE5ADC4C87BE10601BD05C506E0FEAC9AC19B9281B7CD01DE98FABB55C6EF8797E8430275939763BFDDE4A89846713F87D3C91B1D1DFBFECFF6483BEBE04343EE36DB8C7BA7F5201106B3DE37428C3A4011B27E3354D9142D6D6AFE5E63DA14317D18B536064CE172C207532F5C1B8F11ACD3627824F165761FF9C18CD326385F4FA2C2D13FBE2B58D8D575FBDDE3BB885717997EF0F82E3599E6AB9612EE5F54B3BC6CCC175F64AB1550776FEA27E9EB553625B44FB65F7F94BE5B94CBE6B38FE66DBB7A74F76EC3A09BF1A298D655539DB7E369B5B89BCDAABB7B3B3B0777771EDE5D088CBBD3C09A3FEE606B7BA2DC7F769177BEC5F2CA2C7F56D44DFB346BB349D610D54F668B68B3936CB17A3AC187F9BBCE646AAF4439D39FB248B65CE6338E57FA938637B09A655EC1EF66994A7A1B9F3E7B7AFC7C6CA17481384A3EA3C12D68CA799C3A4AE19BE177E9EDD7D3ACCCEA9775B5CAEBF65A913E9B110DAA72BD58BABFBB3CB7E9ED2FCB1E00FEE8F630F06F08423EE943787CB743802E99957B3D3A77C4BE3B73B79B572B8D1F32AD03B9ECDBCCEAE0ABFFEF9D5456495D34EC87B787F3FF7AE650A7E50338236A2E6EC11603EFFDBF97279E16CDAACCAEFB531A7C717B78AFE755DDF6A1791FFFBF864BBAEBFA1FC4305D605F83776E06F1FF5E36FAE1AB9621085FD56508803FF87F0DD39D2D67C56531230F0D6E4C5D4CD6ED07725E14E2D760BF5BC2F9FF3F0FB233DA6744EFE3DBC37A9EC540B94FFF5FC3971B3373B7E6C5C1CCE82DF86FC3BB3FE2B9F781F5FE3C3704E9CD55D1D284F481055FDC1EDEE9222BCAE3D98C66BAE9902CF8E6F610BF6AF2FA6C9633179D35CD1A39FC40F947BEFF7AD0E92BD28E9BE0BB165FAF8793322B1610ADE12EBC261FD0C70DF0DF0BF6B2F845EBDC81382F7A148AB6788F1EE84D466B9879069ADCBE8FEFE693A668F39EEBE07F7E7B684FCAEAA207CA7E787B385F5493A2CC5FCEAB658723822F6E0FEFF5BCA8DBD7C50F7AAEB9FDF8F6B04EEA9C9607665FBD390981F99FFFBFC6B6DD66F1E9D626AE0BEC6B58BA9B410C91DDBED23539C117B79F46C5A40BCDFBF8FF6D93F84DCCDDD79FB2DBCFD4FF7F5C9337455B76CDBF7C747B184FF3665A172B24E64348C117B787A7D3F105E99ABAC8CAA6A76EA30D6E0FFFE756BDBDCEDBF7920C4AD4CFD6653EFB4644A403ECEBC8CA8D20FEDF2B34AFAA6AD1C5C27C767B285F47AD0E8B9FAC977581F99FFFBF464983541FC47E00F035582EFEDAFF7BD9EC89AE1E7431F13FBF3D34FC1BC2914FFE5FC3166ECDF703586368A1FB16EC31FCEAFF7B59E49B32DFB7678E41E34D46B463B5F993DB4378DD66758B49E8E843F7F1ED61D1527B1F92FDF0FF352CAFBAFE43179E1D98AFC1F69B5EFE7F2FE37FA3C633EBA958FDE8FF358CF2A11CF2F558E3FF633CF1C357863F47DCF07A95676FF3FA152958FDF58398A30FEE6BF0CA6D80FCBF9775BEF1948990A01F717A9FFFBF869DEC189F14D5459DADE645FE41FCD48377FD35F8E936407E76F8E99BE6052C94D26B212CFBE1FF6BB8C01360D6991FC4025D605F83016E06F1B333FDDF843AF9A62C11BFD25322EED3FF17310F6594AA0F35430CE36BB1CAC09B3F4B1CB2C82EFACB40EED3F784F4EDBCB89877D443F0C57BC2FB6E316BE71170FAF97B40FB7F9124E0DFDBF96443107A13F6FF2E097A93356F3F487C00E06BC84EFCB59F25C1F9FF1543BDA8DABCB3C6AC1FFD5098EAD64CF5FB0F25B6DE97BB8621DD92CF3601F87F2FC701F37E7E403E7B3F288359FACE77FFAFE29F6F262DEB01FA9ACCF3FF45D6F9FF76527408CE4FD2EB14BD50D6E1459ECFF20E91FADFFEF0D9F9B869AA699161C1B8C7D36C2B7E7F4D14DA908EB4F620F30EBE31904AB54D2212338B99B33EECDFFF75B5AEA77944546EC5E90235C6EFA09CC5E1EBA3F726AB2FF298247FA311F58048BC77EA77E3A029129F15E094F4AC79B12ECBCF3E3ACFCAA62B2503047D7C37CA6A5E1BC3AA08F8B36299D7DD265616F413FB77633E009B91FFFE057165693E64E2CCF345C6446956D954F9F65951372D69996C92353916D917D947298DFDB298E53551E9BA69F3C5180DC6AF7F5179521639B210A6C117D9B238CF9BF64DF5365F7EF6D1DECECEC147E97159640D085C9E7F94BE5B944BFA63DEB6AB4777EF36DC41335E14D3BA6AAAF3763CAD1677B35975975E7D787767EF6E3E5BDC6D9A59E9F38A6739744E9F64CB653EEBE59B1FFF5E796FBECC3CBECACF3DEEEF4E4BF745FB9AF70EFAFFECA302E36749FE3CA7E921FD3C7B99B5C4934BB4CA19D38F527046362973CB1D9D0EE3C6C3EBC10168EBF58DEFE35FF3FAF232ABA7F3ACFE28FD227BF73C5F5EB4F3CF3EDADD3BB801295F876EA6BD2E27FF88F44ED43B38BE270A3FCCD98BE4C67EDE4EDDD3A25995D9F53740FE3EECD7F3AA6E6F847C6FEF9B9AD7936AB1582FE159C4925B3F6FA7F8FF1DD2D907CAC9A44D3077F6F6BF29D638238785ACF53A2BE154D4C564DDFE883FBE39FE600FEA6785499E67DF08E05B33CA4020F223E6F8FF3173F401BFB92A40F8F7857D2B822EB2A23C9ECD88CF3480BE1DEC5BE1FD5583B85058E5AC69D6C4C69BBAD8BBFFE90775F15243A09FD54E4ECAAC5800FECF7E2F1B7BB8BF7B93A312E96159FCA275EEFA392F6E20D6EECEFD9DF7EF85E033FE5F97B76EC3B7DFCD274DD1E6EF6BB46F03FA49595DFC6CC0FDA29A1465FE725E2D857706792720F96D20BF9E1775FBBAF8C10DDAE1BDE19ED439D4FE576F4E0CE019FDDD165043DF8C7DDB9C6FBB9D99DB98828AB41F4C33DD6C1D83AEBEBE09F230F8FA405C42EB96D6F47D27E5EBCCC5D721EAFFFF5D8E37455BBE97E5BE15D4A77933AD8B15F2961B61EFEFECBCBF12571EF882E6A02EE8851B15E2FBABF01F8276A1DCE66C5DE6B31F71B4FFFEABAA5A7C18437F230ACC5F2FBD2D945B4F3DC6F8A3E9E6F79F6876F87DE8DC87827FDF47037CC8E4C5178A7FDE4EE0376081BE81D98B18205E097F2FD51D51256E1D5C207D2D28760DFCD6306ECD8CAAEB7E882B5BDF8C76CD3E50E0FF5F2514B79EAD1FE234FDBF8A40FF6FD51AB79EB8D7AB3C7B9BD7AF8878FAEB0F6B1EBFA1A0EE6BB1C3FB80FF307650A2DEE4C77712571F208996AC4F8AEAA2CE56F3EB1FD684FE2CCFC437C42F58F9C9F1DE86D9B845E876EBF9F004EC472BCEDFA89A64103F3CC1FAFFD972F222BB78EF34EEED217F3B2F2EE656C8BECEEC3298EF16B376FE41507EEED9F41BB0E67DA0DFC0CCDD9AF1DF64CDDBFFBF70FDECCBFF5FB2C38BAACD6F58EBB971E5E4BDF8A1F9FD7F942C08DE07513E8C3100E1673537E777F0A359E3F7FF3F9D4AE9C3F8C9AA5C93779BD7CD8B3C9FE5DF00131D374D352D322C76681F4F34ADF9FBC7BC591A44FAAA421FF2ADF6FF3A2FCFC7FAC917EBB22D566531A5DE482DF586E440989E0228EEC310D0B77A808871F31A7C9595E4F3376D9D1119FA5C5E2CA7C52A2B03B43BAD6E290DA0A285D7FDE669BECA9760F3EEE06ED397353BFD0E2DDC8E60DE34FAC777BDA9DD3CE327D562B15E1295D503FED99FF96E8F01B4FE97FFDFE684DE786ED3E7CF2D479C2D67C565315B33A4B62E26EBF687C116D16E0390032DFEBFCD20F141DDA6E39F5B2EB1099B9F7DCEB05D0560BC4FFFBFCD016E20B7E9ECE776D67515C54DFE00F25F7FF6363142B7F70062FFCB9F15B678BFD9FA40D6E88DE9367D06A9D4FF7770897E30C823E6FBC87CFE7F8D3FA243D596FF6FE00E6F1DF4E78437587F1986B0A8371F6A3F76C6E3FFB773C60FCDA07C2DBE9079F939630BC5F967DF99780F55F3FFD179BF55573FC76EC4749ECFD6653E33D3FEAAAA1683B3CE5FFAF3251FBCC79C77BA0B27BFF7E5CF0A17F447A8CDBE6926E80EE7367D02B9FFF730C3D7F71664F2FE3FC415EF33493F178CF173ED2DF4786320C5ED66D536F067D37DF8FF2DA5111FAD36FD7F037FF84B1A3F270C02CDF5FB3F89A65BBDB9B40DFC39741FDE9E296E658ABEA1C98F8F4A9B7EC3937F6BEB6490FA399B70C3713FFB9EE27B69926F68CE7F68BEE27B69969F636751F4D19BECE287E619D81E6390F8E39F95D97F1FCDFB81F3EF8DE536BDFD9CFB018E077A28FB22DB99B1C854FDBF71DE6F3B0B3FDC39A7763F67F38D89FED957F03773CB3734C13F3CB57ECBB9FD39D6E8AB3C7B9BD7AFB236D75F7FC8EB08BDFE43798F7CFDB3C216EF97A1FB40D6888CEA36BDFEDCAF26580C9E14D5459DADE6D73F5C6EE9F71F87E97DFDFF7D6E898CEA36BDFEDC738BC7E692D2FE593723DD1E87744914F037C41B3F3403D31BCF6DFAFCB9B63604A0AA7F188CC01D75E65F3FFBFFFAB4CB306ED3D5CFED6CBFC99AB73FFB538D5E3ABE233EF8FFF624F3186ED3CFCFFD0C373611FCFB7B589B77DE739E6E9A68D7590F94FFD5CFCAE4DF7A4EBE81B9F706739B1EF1CAFF9B98E0E6A501BF517726BFCE12C1FF1B98E3BDA6ECE786497EC88B04A7F44E7B4DEFB4F4465E2B2227D52C7F56D44DFB346BB349D6E43D36C15BAFF356DB3FC996CB7CC62901F9CA5F3970DF61D564917DF6D16C52D1FC671390693AFDFD6D8B26C23E9D8EEC3244BF1FFBD55037DAE0E65ED4C2F5BAD0CF07E0F3B737033FA9168BF5121F196FA7D74FBFC94097DD8637F77EB69C1597C56CCD7CD2D6C564DD46511868378047B4F5CDC87811660F01EFBB814E6D8B9B3BD264DEA6FEFA4D06BAED36BC75EFC39DDED4D72DBAE82DB1F6FBEA35E14E239D761ADEDCBBACEBF57A948F077AC19737437636A107DD7D35D0031ABCA60637F7E2E7AC87E6689302734D6EEE2BDEC926E8B7021B4BC3F58712693434A45ED39B7188257786E5DA6B7493809BA6457E3312FD1CC226326CD6E8FD8637763EA4D26FD2E4B756E0E2934718081F0F7210B922B782EC7B61D13EFC069B7A7B0FE90B1DCA68AFB7EA73B847CFF7E9BB121AFFA65EA38E47118B90791C9D18D90ECC7ED273E0DC3B5D4F865F731F7646E0BB6FD4F216C3EBBA06C3C31C68F9CD0E77C8EBE1D7FB5F7EF0F0A31EC9300D3635FF6609B1D1016318032D3E9824569D0E93A1DBE49B1D7ACFFDE2F7BC4F3F78885DDFCC9990D86837B4FEC60611BC3BE4863288FE97DF3C39ACEB770B6298B6370E27368AFF5791813933E6B7F7A930D4F49B15841F360114E4B0DC870D7E56067B1B2EF93A43EB042BBFBF041D9121461B0EA3EDC7348CB37CB069A00331988CB8F7E5373FF44DD23DD4F61B99B7FF7791C1398BB7A0C3507ECE1B50D737E581B80FFF5F440AB0A84D73C586EF35A006C388BF9773FAFE62F335866693D7833AACD3E29B5562EFC5035F6378CA0314EADFC246FBAD7E16E4D776127B953FFE2687CB00370E152D36CC4C07CF08823FF4E101EB613EB55F7EC32C7A3321BEC650FA79A01B7CEA4DED8791FF20AF7A30F525331BF9FA83C9D2CF626D26CBC6F63F3B648925DA6240BCAF3F982CDD84D9068F33DEF29B1589A15C60972FA290BED6F06F48B5FC6C66586289956F2E9F8204DB269D66BFFD6607E5673B55ABE1836F64389D15F1A171759B7D20B2BD37FA2957FBAEFFD5CFC6903779CA9B9A6F1ED0E0706EE533FF6C90E4F15D816297B9ED778FEF4A42593FA03F29D7965DE45F54B3BC6CF8535A5C5FD3DB8B5CFE7A9A37C58503F198602EF329FA74404D9BB3E5796556F93B189926E66B9DA42FF2369BD19AFB71DD16E7D9B4A5AFA7F04CE075FF6456AE21468B493E3B5B7EB96E57EB96869C2F2665A0BB1FDFDDDCFFE3BB3D9C1F7FB9C25FCD37310442B3A021E45F2E3960B0783FCBCA260F276D08C40951FFF39C3E97B96CE9677E716D21BDA896B704A4E47B9AAFF2E58C74CD9B7CB12A0958F3E5F27576990FE376330D438A3D7E5A646445173E05E513631A32EAD9EB823AF0DF70FDD19FC4AEB3C5BBA3FF270000FFFF63E460029A5D0100, '4.3.1')


--********************************************************
--********************************************************
--Additional Indexes - keep in sync with index creation in Configurations.cs

        -- KEEP THIS COMMENT - used to sync compare with schema SQL file
        -- Quote the commented out drop statements so they will compare when comparing this with Configuration.cs

--        private static class CreationSql
--        {

--'Drop Index cc_000'

--'Drop Index cc_BannedTags.UQ__BannedTags_Name'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_BannedTags', @IndexName = 'UQ__BannedTags_Name';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__BannedTags_Name] on dbo.cc_BannedTags( Name  );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_Buildings.UQ__Buildings_Name4Event'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_Buildings', @IndexName = 'UQ__Buildings_Name4Event';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__Buildings_Name4Event] on dbo.cc_Buildings( EventId, Name  );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_CommunitySponsors.UQ__CommunitySponsors_Name4Event'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_CommunitySponsors', @IndexName = 'UQ__CommunitySponsors_Name4Event';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__CommunitySponsors_Name4Event] on dbo.cc_CommunitySponsors( EventId, Name  );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_Events.UQ__Events_DisplayName'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_Events', @IndexName = 'UQ__Events_DisplayName';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__Events_DisplayName] on dbo.cc_Events( DisplayName );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_Events.UQ__Events_ShortName'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_Events', @IndexName = 'UQ__Events_ShortName';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__Events_ShortName] on dbo.cc_Events( ShortName );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_IndividualContributors.UQ__IndividualContributors_Names4Event'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_IndividualContributors', @IndexName = 'UQ__IndividualContributors_Names4Event';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__IndividualContributors_Names4Event] on dbo.cc_IndividualContributors( EventId, FirstName, LastName  );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_Presenters.UQ__Presenters_EmailAddress4Event'
--Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
--Select @SchemaName = 'dbo', @TableName = 'cc_Presenters', @IndexName = 'UQ__Presenters_EmailAddress4Event';
--Set @SchemaTableName = @SchemaName + '.' + @TableName;
--If OBJECT_ID(@SchemaTableName,'U') is null Begin
--	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
--End Else Begin
--	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
--		Print 'Index ' + @IndexName + ' exists.';
--	End Else Begin
--		Create unique index [UQ__Presenters_EmailAddress4Event] on dbo.cc_Presenters( EventId, EmailAddress );
--		Print 'Created Index ' + @IndexName;
--	End;
--END;
--GO

--'Drop Index cc_Presenters.UQ__Presenters_UniqueUserIdentifier'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_Presenters', @IndexName = 'UQ__Presenters_UniqueUserIdentifier';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__Presenters_UniqueUserIdentifier] on dbo.cc_Presenters( EventId, UniqueUserIdentifier );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_Rooms.UQ__Rooms_Name4Building'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_Rooms', @IndexName = 'UQ__Rooms_Name4Building';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__Rooms_Name4Building] on dbo.cc_Rooms( BuildingId, Name );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_Sessions.UQ__Sessions_Title4Event'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_Sessions', @IndexName = 'UQ__Sessions_Title4Event';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__Sessions_Title4Event] on dbo.cc_Sessions( EventId, Title  );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_SessionTags.UQ__SessionTags_Tags4Session'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_SessionTags', @IndexName = 'UQ__SessionTags_Tags4Session';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__SessionTags_Tags4Session] on dbo.cc_SessionTags( SessionId, TagId  );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_ShirtSizes.UQ__ShirtSizes_Size'
--Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
--Select @SchemaName = 'dbo', @TableName = 'cc_ShirtSizes', @IndexName = 'UQ__ShirtSizes_Size';
--Set @SchemaTableName = @SchemaName + '.' + @TableName;
--If OBJECT_ID(@SchemaTableName,'U') is null Begin
--	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
--End Else Begin
--	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
--		Print 'Index ' + @IndexName + ' exists.';
--	End Else Begin
--		Create unique index [UQ__ShirtSizes_Size] on dbo.cc_ShirtSizes( Size );
--		Print 'Created Index ' + @IndexName;
--	End;
--END;
--GO

--'Drop Index cc_Sponsors.UQ__Sponsors_Name4Event'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_Sponsors', @IndexName = 'UQ__Sponsors_Name4Event';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__Sponsors_Name4Event] on dbo.cc_Sponsors( EventId, Name );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_Tags.UQ__Tags_Name4Event'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_Tags', @IndexName = 'UQ__Tags_Name4Event';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__Tags_Name4Event] on dbo.cc_Tags( EventId, Name );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO

--'Drop Index cc_zzz'
